package com.yimi.yinhepda.db.table;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.yimi.yinhepda.entity.bean.MoveStockScanChildEntity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author: lj
 * Date: 2018/12/28
 * Description: 移库装卸车扫描主单表
 */
@DatabaseTable(tableName = "MoveStockScanMasterTable")
public class MoveStockScanMasterTable implements Serializable{
    @DatabaseField(generatedId = true)
    private transient Long id;
    /**
     * 操作人
     */
    @DatabaseField
    private String operCode;
    /**
     * 1-装车，2-卸车，11-取消卸车
     */
    @DatabaseField
    private int operType;
    /**
     * 是否强扫：0-不是，1-是
     */
    @DatabaseField
    private int isForceScan;
    /**
     * 移库任务号
     */
    @DatabaseField
    private String taskNo;
    /**
     * 运单号
     */
    @DatabaseField
    private String waybillNo;
    /**
     * 移出场地
     */
    @DatabaseField
    private String moveOutCode;
    @DatabaseField
    private String moveOutName;
    /**
     * 移入场地
     */
    @DatabaseField
    private String moveInCode;
    @DatabaseField
    private String moveInName;
    /**
     * 库存件数
     */
    @DatabaseField
    private int stockNum;

    /**
     * 是否上传：0-未上传，1-上传
     */
    @DatabaseField
    private int isUpload;
    /**
     * 创建时间
     */
    @DatabaseField
    private Date createTime;

    private int getType;

    private List<MoveStockScanChildEntity> childEntityList;

    public MoveStockScanMasterTable() {
        createTime = new Date();
    }

    public int getScanCount(){
        if(childEntityList == null || childEntityList.isEmpty()){
            return 0;
        }
        int count = 0;
        for(MoveStockScanChildEntity childEntity : childEntityList){
            if(childEntity.getFlag() == 1){
                count++;
            }
        }
        return count;
    }

    public int getDiffCount(){
        return getScanCount() - stockNum;
    }

    public int getType() {
        int dif = getDiffCount();
        if (getScanCount() == 0) {
            //白色
            return 1;
        } else if (dif < 0) {
            //红色
            return 0;
        } else if (dif > 0) {
            //黄色
            return 2;
        } else {
            //绿色
            return 3;
        }
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public int getIsUpload() {
        return isUpload;
    }

    public void setIsUpload(int isUpload) {
        this.isUpload = isUpload;
    }

    public int getGetType() {
        return getType;
    }

    public void setGetType(int getType) {
        this.getType = getType;
    }

    public String getOperCode() {
        return operCode;
    }

    public void setOperCode(String operCode) {
        this.operCode = operCode;
    }

    public int getOperType() {
        return operType;
    }

    public void setOperType(int operType) {
        this.operType = operType;
    }

    public int getIsForceScan() {
        return isForceScan;
    }

    public void setIsForceScan(int isForceScan) {
        this.isForceScan = isForceScan;
    }

    public List<MoveStockScanChildEntity> getChildEntityList() {
        return childEntityList;
    }

    public void setChildEntityList(List<MoveStockScanChildEntity> childEntityList) {
        this.childEntityList = childEntityList;
    }

    public String getTaskNo() {
        return taskNo;
    }

    public void setTaskNo(String taskNo) {
        this.taskNo = taskNo;
    }

    public String getWaybillNo() {
        return waybillNo;
    }

    public void setWaybillNo(String waybillNo) {
        this.waybillNo = waybillNo;
    }

    public String getMoveOutCode() {
        return moveOutCode;
    }

    public void setMoveOutCode(String moveOutCode) {
        this.moveOutCode = moveOutCode;
    }

    public String getMoveOutName() {
        return moveOutName;
    }

    public void setMoveOutName(String moveOutName) {
        this.moveOutName = moveOutName;
    }

    public String getMoveInCode() {
        return moveInCode;
    }

    public void setMoveInCode(String moveInCode) {
        this.moveInCode = moveInCode;
    }

    public String getMoveInName() {
        return moveInName;
    }

    public void setMoveInName(String moveInName) {
        this.moveInName = moveInName;
    }

    public int getStockNum() {
        return stockNum;
    }

    public void setStockNum(int stockNum) {
        this.stockNum = stockNum;
    }
}
